package com.itheima.reggie.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * mybatisplus 配置
 *  1. 分页的拦截器
 */

@Configuration
public class MybatisPlusConfig {
    
    /**
     * 配置分页拦截器
     * @return
     */
    @Bean
    public MybatisPlusInterceptor mpi(){
        
        //1. 创建mybatisplus拦截器
        MybatisPlusInterceptor mpi = new MybatisPlusInterceptor();
        
        //2. 添加分页的拦截功能
        mpi.addInnerInterceptor(new PaginationInnerInterceptor());
        
        //3. 返回拦截器
        return mpi;
    }
}
